from django.db import models


# Create your models here.
# 学生表
class Student(models.Model):
    s_id = models.BigAutoField(primary_key=True, verbose_name='学生编号')
    c_name = models.CharField(max_length=10, verbose_name='班级姓名')
    s_name = models.CharField(max_length=10, verbose_name='学生姓名')
    s_code = models.CharField(max_length=32, unique=True, verbose_name='学籍号')
    s_age = models.PositiveSmallIntegerField(verbose_name='学生年龄')
    s_gender = models.CharField(max_length=2, verbose_name='学生性别', choices=[('1', '男'), ('0', '女')])
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    class Meta:
        verbose_name_plural = verbose_name = '学生表'


# 教师表
class Teacher(models.Model):
    t_id = models.BigAutoField(primary_key=True, verbose_name='教师编号')
    t_major = models.CharField(max_length=10, verbose_name='科目名称')
    t_name = models.CharField(max_length=10, verbose_name='教师姓名')
    t_gender = models.CharField(max_length=2, verbose_name='教师性别', choices=[('1', '男'), ('0', '女')])
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    class Meta:
        verbose_name_plural = verbose_name = '教师表'


# 班级表
class Class(models.Model):
    c_id = models.BigAutoField(primary_key=True, verbose_name='班级编号')
    t_id = models.BigIntegerField(verbose_name='教师编号')
    c_name = models.CharField(unique=True, max_length=10, verbose_name='班级姓名')
    c_grade = models.CharField(max_length=2, verbose_name='学生年级', choices=[('1', '一年级'), ('2', '二年级'), ('3', '三年级')])
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    class Meta:
        verbose_name_plural = verbose_name = '班级表'


# 分数表
class Score(models.Model):
    f_id = models.BigAutoField(primary_key=True, verbose_name='分数编号')
    s_id = models.BigIntegerField(verbose_name='学生编号')
    l_name = models.CharField(max_length=10, verbose_name='科目名称')
    f_score = models.CharField(max_length=4, verbose_name='科目分数')
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    class Meta:
        verbose_name_plural = verbose_name = '分数表'


# 用户表
class Account(models.Model):
    a_id = models.BigAutoField(primary_key=True, verbose_name='用户编号')
    t_id = models.BigIntegerField(unique=True, verbose_name='教师编号')
    username = models.CharField(max_length=8, unique=True, verbose_name='用户名')
    pwd = models.CharField(max_length=32, null=True, verbose_name='密码')
    pwd_salt = models.CharField(max_length=8, null=True, verbose_name='密码盐')
    level = models.CharField(max_length=2, default='1', verbose_name='权限')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='注册时间')
    edit_time = models.DateTimeField(auto_now=True, verbose_name='修改时间')

    class Meta:
        verbose_name_plural = verbose_name = '用户表'


# 科目表
class Lesson(models.Model):
    l_id = models.BigAutoField(primary_key=True, verbose_name='科目编号')
    l_name = models.CharField(max_length=10, unique=True, verbose_name='科目名称')

    class Meta:
        verbose_name_plural = verbose_name = '科目表'
